package com.qibo.setting;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.hjq.toast.ToastUtils;
import com.qibo.baselib.base.BaseActivity;
import com.qibo.baselib.utils.AppManager;
import com.qibo.baselib.utils.UpDateAppUtil;

@Route(path = "/settingmodule/SettingMainActivity")
public class SettingMainActivity extends BaseActivity implements View.OnClickListener{

    private ImageButton imageButton;
    private TextView textView_titleBar;
    private TextView textView_Right_titleBar;
    private RelativeLayout settingmodule_rl_switch;
    private RelativeLayout settingmodule_rl_account;
    private RelativeLayout settingmodule_rl_signin;
    private RelativeLayout settingmodule_rl_version;
    private RelativeLayout settingmodule_rl_log;
    private RelativeLayout settingmodule_rl_dropout;

    @Override
    protected int getContentViewId() {
        return R.layout.settingmodule_activity_main;
    }

    @Override
    protected void initView() {
        imageButton = findViewById(R.id.btnBack_pay1);
        textView_titleBar = findViewById(R.id.textView_titleBar);
        textView_Right_titleBar = findViewById(R.id.textView_Right_titleBar);
        settingmodule_rl_switch = findViewById(R.id.settingmodule_rl_switch);
        settingmodule_rl_account = findViewById(R.id.settingmodule_rl_account);
        settingmodule_rl_signin = findViewById(R.id.settingmodule_rl_signin);
        settingmodule_rl_version = findViewById(R.id.settingmodule_rl_version);
        settingmodule_rl_log = findViewById(R.id.settingmodule_rl_log);
        settingmodule_rl_dropout = findViewById(R.id.settingmodule_rl_dropout);
    }

    @Override
    protected void initAction() {
        imageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();;
            }
        });
        textView_titleBar.setText("设置");
        settingmodule_rl_switch.setOnClickListener(this);
        settingmodule_rl_account.setOnClickListener(this);
        settingmodule_rl_signin.setOnClickListener(this);
        settingmodule_rl_version.setOnClickListener(this);
        settingmodule_rl_log.setOnClickListener(this);
        settingmodule_rl_dropout.setOnClickListener(this);
    }
    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View view) {
        int i = view.getId();
        if (i == R.id.settingmodule_rl_switch) {
            ToastUtils.show( "账号切换");

            /**账户*/
        } else if (i == R.id.settingmodule_rl_account) {
            /**签到*/
        } else if (i == R.id.settingmodule_rl_signin) {
            ToastUtils.show( "签到");

            /**版本信息*/
        } else if (i == R.id.settingmodule_rl_version) {
            UpDateAppUtil.getUpdateInfo(SettingMainActivity.this,"http://paywhere.kongzue.com/downloads/paywhere.apk","V3.6.5");
            /**上传日志*/
        } else if (i == R.id.settingmodule_rl_log) {
            ToastUtils.show( "上传日志");
            /**退出账号*/
        } else if (i == R.id.settingmodule_rl_dropout) {
        AlertDialog dialog = new AlertDialog.Builder(this).setTitle("提示")
                .setNegativeButton("取消", null).setPositiveButton("确定", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        AppManager.getInstance().AppExit(mContext);
                    }
                }).setMessage("是否退出账户？").create();
        dialog.show();

        }
    }
}
